/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on 5/10/2009, 3:54:45 AM
 */

package nz.ac.massey.spidernetpn.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Paint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import java.util.List;
import java.util.Random;

import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.JToolTip;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;

import org.apache.commons.collections15.Transformer;


import edu.uci.ics.jung.algorithms.cluster.EdgeBetweennessClusterer;
import edu.uci.ics.jung.algorithms.layout.AbstractLayout;
import edu.uci.ics.jung.algorithms.layout.AggregateLayout;
import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.algorithms.layout.FRLayout;
import edu.uci.ics.jung.algorithms.layout.FRLayout2;
import edu.uci.ics.jung.algorithms.layout.ISOMLayout;
import edu.uci.ics.jung.algorithms.layout.KKLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.algorithms.layout.SpringLayout;
import edu.uci.ics.jung.algorithms.layout.util.Relaxer;
import edu.uci.ics.jung.graph.DirectedGraph;
import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.graph.event.GraphEvent.Edge;
import edu.uci.ics.jung.graph.util.EdgeType;
import edu.uci.ics.jung.graph.util.Graphs;
import edu.uci.ics.jung.graph.util.Pair;
import edu.uci.ics.jung.visualization.BasicVisualizationServer;
import edu.uci.ics.jung.visualization.GraphZoomScrollPane;
import edu.uci.ics.jung.visualization.LayeredIcon;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse;
import edu.uci.ics.jung.visualization.control.GraphMouseAdapter;
import edu.uci.ics.jung.visualization.control.GraphMouseListener;
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
import edu.uci.ics.jung.visualization.decorators.DefaultVertexIconTransformer;
import edu.uci.ics.jung.visualization.decorators.EllipseVertexShapeTransformer;
import edu.uci.ics.jung.visualization.decorators.PickableEdgePaintTransformer;
import edu.uci.ics.jung.visualization.decorators.PickableVertexPaintTransformer;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
import edu.uci.ics.jung.visualization.decorators.VertexIconShapeTransformer;
import edu.uci.ics.jung.visualization.renderers.Renderer;

import nz.ac.massey.spidernetpn.database.GraphDatabase;
import nz.ac.massey.spidernetpn.webcrawler.FoundMaxException;
import nz.ac.massey.spidernetpn.webcrawler.WebCrawler;
import javax.swing.plaf.metal.*;

/**
 * 
 * @author Eric
 */
public class MainFrame extends javax.swing.JFrame {

	/** Creates new form MainFrame */
	public MainFrame() {
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		initComponents();
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		
		mainPanel = new javax.swing.JPanel();
		optionsFlowPanel = new javax.swing.JPanel();
		optionPanel1 = new javax.swing.JPanel();
		jLabel1 = new javax.swing.JLabel();
		urlField = new javax.swing.JTextField();
		goButton = new javax.swing.JButton();
		pauseButton = new javax.swing.JButton();
		advanceButton = new javax.swing.JButton();
		useProxyCheck = new javax.swing.JCheckBox();
		useClustering = new javax.swing.JCheckBox();
		jPanel1 = new javax.swing.JPanel();
		optionLabel = new javax.swing.JLabel();
		maxDepthLabel = new javax.swing.JLabel();
		maxDepthField = new javax.swing.JTextField();
		jLabel2 = new javax.swing.JLabel();
		graphDetailLabel = new javax.swing.JLabel();
		maxNodeLabel = new javax.swing.JLabel();
		maxNodeField = new javax.swing.JTextField();
		graphLabel = new javax.swing.JLabel();
		graphComboBox = new javax.swing.JComboBox();
		graphDetailComboBox = new javax.swing.JComboBox();
		mouseLabel = new javax.swing.JLabel();
		mouseComboBox = new javax.swing.JComboBox();
		minimizeButton = new javax.swing.JButton();
		redrawButton = new javax.swing.JButton();
		graphPanel = new javax.swing.JPanel();
		statusPanel = new javax.swing.JPanel();
		nodeCountLabel = new javax.swing.JLabel();
		countLabel = new javax.swing.JLabel();
		jProgressBar_MainFrame = new javax.swing.JProgressBar();
		menuBar = new javax.swing.JMenuBar();
		fileMenu = new javax.swing.JMenu();
		newOption = new javax.swing.JMenuItem();
		loadOption = new javax.swing.JMenuItem();
		saveOption = new javax.swing.JMenuItem();
		exitMenu = new javax.swing.JMenuItem();
		optionMenu = new javax.swing.JMenu();
		placeholderAction = new javax.swing.JMenu();
		FH = new javax.swing.JMenuItem();
		office = new javax.swing.JMenuItem();
		motif = new javax.swing.JMenuItem();
		Windows = new javax.swing.JMenuItem();
		metal = new javax.swing.JMenuItem();
		changeLayout = new javax.swing.JMenu();
		menuFRLayout = new JMenuItem();
		setGraphFolder = new JMenuItem();
		
		setTitle("Web Crawler");
		setMinimumSize(new java.awt.Dimension(1000, 600));
		setName("Main Frame"); // NOI18N
		getContentPane().setLayout(
				new javax.swing.BoxLayout(getContentPane(),
						javax.swing.BoxLayout.Y_AXIS));

		mainPanel.setLayout(new javax.swing.BoxLayout(mainPanel,
				javax.swing.BoxLayout.Y_AXIS));

		optionsFlowPanel.setPreferredSize(new java.awt.Dimension(900, 80));
		optionsFlowPanel.setLayout(new java.awt.FlowLayout(
				java.awt.FlowLayout.LEFT, 2, 2));

		optionPanel1.setMaximumSize(new java.awt.Dimension(2000, 40));
		optionPanel1
				.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

		jLabel1.setText(" URL :");
		optionPanel1.add(jLabel1);

		urlField.setText("http://www.google.com");
		urlField.setPreferredSize(new java.awt.Dimension(450, 20));
		optionPanel1.add(urlField);

		goButton.setText("Go");
		goButton.setFocusable(false);
		goButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		goButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		goButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				goButtonActionPerformed(evt);
			}
		});
		optionPanel1.add(goButton);

		pauseButton.setText("Pause");
		pauseButton.setEnabled(false);
		pauseButton.setFocusable(false);
		pauseButton
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		pauseButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		pauseButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				pauseButtonActionPerformed(evt);
			}
		});
		optionPanel1.add(pauseButton);

		advanceButton.setText("Advanced");
		advanceButton.setFocusable(false);
		advanceButton
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		advanceButton
				.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		advanceButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				advanceButtonActionPerformed(evt);
			}
		});
		optionPanel1.add(advanceButton);

		useProxyCheck.setText("Use Proxy");
		useProxyCheck.setFocusable(false);
		useProxyCheck
				.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
		//useProxyCheck.setPreferredSize(new java.awt.Dimension(85, 30));
		useProxyCheck
				.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		optionPanel1.add(useProxyCheck);

		optionsFlowPanel.add(optionPanel1);

		
		jPanel1.setMinimumSize(new java.awt.Dimension(600, 100));
		//jPanel1.setPreferredSize(new java.awt.Dimension(927, 33));
		jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 7,
				5));

		optionLabel.setText(" Options:");
		jPanel1.add(optionLabel);

		maxDepthLabel.setText(" Max Depth");
		jPanel1.add(maxDepthLabel);

		maxDepthField.setText("2");
		maxDepthField.setPreferredSize(new java.awt.Dimension(25, 20));
		maxDepthField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				maxDepthFieldActionPerformed(evt);
			}
		});
		jPanel1.add(maxDepthField);

//		jLabel2.setText("or");
//		jPanel1.add(jLabel2);

		maxNodeLabel.setText("or Max Node");
		jPanel1.add(maxNodeLabel);

		maxNodeField.setText("75");
		maxNodeField.setPreferredSize(new java.awt.Dimension(40, 20));
		jPanel1.add(maxNodeField);

		mouseLabel.setText("Mouse Mode");
		jPanel1.add(mouseLabel);
		
		mouseComboBox.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "Move Tool", "Picking Tool"}));
		mouseComboBox.setPreferredSize(new java.awt.Dimension(75, 20));
		mouseComboBox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						mouseComboBoxActionPerformed(evt);
						
						if(vv2==null){
							return;
						}
						
						ModalGraphMouse gm = new DefaultModalGraphMouse<URL, Integer>();
						if (mouseComboBox.getSelectedIndex() == 1) {
							gm.setMode(ModalGraphMouse.Mode.PICKING);
							vv2.setGraphMouse(gm);
						}
						else
						{
							gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
							vv2.setGraphMouse(gm);
						}
						
					}
				});
	//	 DefaultModalGraphMouse<Integer,Number> graphMouse = new DefaultModalGraphMouse<Integer,Number>();
	  //      vv.setGraphMouse(graphMouse);
		
		//mouseComboBox = graphMouse.getModeComboBox();
	    //    modeBox.addItemListener(((DefaultModalGraphMouse<Integer,Number>)vv.getGraphMouse()).getModeListener());
		
		

		jPanel1.add(mouseComboBox);
			
				graphDetailLabel
				.setText("Graph Detail");
		jPanel1.add(graphDetailLabel);
		
		graphDetailComboBox.setModel(new javax.swing.DefaultComboBoxModel(
				new String[] { "Full", "Reduced"}));
		graphDetailComboBox.setPreferredSize(new java.awt.Dimension(65, 20));
				
		jPanel1.add(graphDetailComboBox);

		

//		graphComboBox.setModel(new javax.swing.DefaultComboBoxModel(
//		new String[] { "KKLayout", "FR2Layout", "SpringLayout", "CircleLayout"}));
//		graphComboBox.setPreferredSize(new java.awt.Dimension(75, 20));
//		graphComboBox
//		.addActionListener(new java.awt.event.ActionListener() {
//			public void actionPerformed(java.awt.event.ActionEvent evt) {
//				GraphComboBoxActionPerformed(evt);
//			}
//		});
//
//		jPanel1.add(graphComboBox);
		
		useClustering.setText("Use Clustering");
		useClustering.setFocusable(false);
		jPanel1.add(useClustering);

//		minimizeButton.setText("Minimize Graph");
//		minimizeButton.setEnabled(false);
//		minimizeButton.addActionListener(new java.awt.event.ActionListener() {
//			public void actionPerformed(java.awt.event.ActionEvent evt) {
//				minimizeButtonActionPerformed(evt);
//			}
//		});
//		jPanel1.add(minimizeButton);

		redrawButton.setText("Redraw Graph");
		redrawButton.setEnabled(false);
		redrawButton.setFocusable(false);
		redrawButton
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		redrawButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		redrawButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				redrawButtonActionPerformed(evt);
			}
		});
		jPanel1.add(redrawButton);

		optionsFlowPanel.add(jPanel1);

		mainPanel.add(optionsFlowPanel);

		graphPanel.setBackground(new java.awt.Color(255, 255, 255));
		graphPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
		graphPanel.setMinimumSize(new java.awt.Dimension(100, 100));
		graphPanel.setPreferredSize(new java.awt.Dimension(800, 600));
		graphPanel.setLayout(new java.awt.BorderLayout());
		mainPanel.add(graphPanel);

		nodeCountLabel.setText(" Node Count: ");

		countLabel.setText("0");

		javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(
				statusPanel);
		statusPanel.setLayout(statusPanelLayout);
		statusPanelLayout
				.setHorizontalGroup(statusPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								statusPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(nodeCountLabel)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(countLabel)//,javax.swing.GroupLayout.PREFERRED_SIZE,53,javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												700, Short.MAX_VALUE)
										.addComponent(
												jProgressBar_MainFrame,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												159,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap()));
		statusPanelLayout
				.setVerticalGroup(statusPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								statusPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												statusPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																statusPanelLayout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																		.addComponent(
																				nodeCountLabel)
																		.addComponent(
																				countLabel))
														.addComponent(
																jProgressBar_MainFrame,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addContainerGap()));

		mainPanel.add(statusPanel);

		getContentPane().add(mainPanel);

		fileMenu.setText("File");

		newOption.setText("New");
		newOption.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				newOptionActionPerformed(evt);
			}
		});
		fileMenu.add(newOption);
		
		setGraphFolder.setText("Graphs Location");
		setGraphFolder.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				SetGraphFolderDialog(evt);
			}
		});
		fileMenu.add(setGraphFolder);

		loadOption.setText("Load");
		loadOption.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				loadOptionActionPerformed(evt);
			}
		});
		fileMenu.add(loadOption);

		saveOption.setText("Save");
		saveOption.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				saveOptionActionPerformed(evt);
			}
		});
		fileMenu.add(saveOption);

		exitMenu.setText("Exit");
		exitMenu.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				exitMenuActionPerformed(evt);
			}
		});
		fileMenu.add(exitMenu);

		menuBar.add(fileMenu);

		optionMenu.setText("Option");

		placeholderAction.setText("Change GUI Theme");
		placeholderAction
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						placeholderActionActionPerformed(evt);
					}
				});
		
		optionMenu.add(placeholderAction);		
		
		placeholderAction.add(office);
		placeholderAction.add(motif);
		placeholderAction.add(Windows);

		placeholderAction.add(FH);
		placeholderAction.add(metal);
		office.setText("Office Theme");
		FH.setText("FH Theme");
		Windows.setText("Windows");
		motif.setText("Motif");
		metal.setText("Metal Theme");
		
		office.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				changeToOffice(evt);
			}
		});
		
		motif.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				changeTomotif(evt);
			}
		});
		
		Windows.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				changeToWindows(evt);
			}
		});

		
		FH.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				changeToFH(evt);
			}
		});
		metal.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
			changeToMetal(evt);
		}
	});
		

		changeLayout.setText("Change Graph Layout");
		
		changeLayout
		.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				changeLayoutActionActionPerformed(evt);
			}
		});
		optionMenu.add(changeLayout);
			
		JMenuItem menuFRLayout = new JMenuItem();
		menuFRLayout.setText("FR Layout");
		changeLayout.add(menuFRLayout);
		
		menuFRLayout.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				menuFRLayout(evt);
			}
		});	
		
		JMenuItem menuKKLayout = new JMenuItem();
		menuKKLayout.setText("KK Layout");
		changeLayout.add(menuKKLayout);
		
		menuKKLayout.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				menuKKLayout(evt);
			}
		});	
		
		JMenuItem menuISOMLayout = new JMenuItem();
		menuISOMLayout.setText("ISOM Layout");
		changeLayout.add(menuISOMLayout);
		
		menuISOMLayout.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				menuISOMLayout(evt);
			}
		});	
		
		JMenuItem menuCircleLayout = new JMenuItem();
		menuCircleLayout.setText("Circle Layout (Fastest)");
		changeLayout.add(menuCircleLayout);
		
		menuCircleLayout.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				menuCircleLayout(evt);
			}
		});	
		
		
		menuBar.add(optionMenu);
		
		setJMenuBar(menuBar);

		pack();
	}// </editor-fold>//GEN-END:initComponents


	int useLayout =0;
	
	protected void menuCircleLayout(ActionEvent evt) {
		// TODO Auto-generated method stub
		if(graph==null){
			return;
		}
		useLayout =1;
		this.RedrawGraph();
	}

	protected void menuISOMLayout(ActionEvent evt) {
		// TODO Auto-generated method stub
		if(graph==null){
			return;
		}
		useLayout =2;
		this.RedrawGraph();
	}

	protected void menuKKLayout(ActionEvent evt) {
		// TODO Auto-generated method stub
		if(graph==null){
			return;
		}
		useLayout =3;
		this.RedrawGraph();
	}

	protected void menuFRLayout(ActionEvent evt) {
		// TODO Auto-generated method stub
		if(graph==null){
			return;
		}
		useLayout =4;
		this.RedrawGraph();
	}

	private void redrawButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_redrawButtonActionPerformed
		// TODO add your handling code here:
		System.out.println("Redraw Button Pressed");
		RedrawGraph();
	}// GEN-LAST:event_redrawButtonActionPerformed

	private static WebCrawler crawler;
	private DirectedGraph<URL, Integer> graph;
	private String filePath = System.getProperty("user.dir")+"/test/graphs/";
	private GraphDatabase graphDB = new GraphDatabase(filePath);

	private void setupWebCrawler() {

		// crawler = new WebCrawler(this.useProxyCheck.isSelected());
		crawler = null;
		graph = null;
		crawler = new WebCrawler(this.useProxyCheck.isSelected());
		crawler.setMaxDepth(Integer.parseInt(this.maxDepthField.getText()));
		crawler.setMaxUrls(Integer.parseInt(this.maxNodeField.getText()));

		graph = crawler.getGraph();

		
		
		// final boolean isMaxURLs = true;
		crawler.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				//crawler.
				
				CrawlerFoundMoreURLs();
			}
		});

	}

	double redrawCount = 1;

	public void CrawlerFoundMoreURLs() {
		// graph = crawler.getGraph();
		Integer vertexCount = graph.getVertexCount();

		 System.out.println("Found More "+vertexCount);
		 
		 
		this.nodeCountLabel.setText("Node Count "+vertexCount.toString());

		if (vertexCount > redrawCount) {
			redrawCount = redrawCount * 2;
			//RedrawGraph();
			drawGraph(graph);
		}
		
		//Work around till crawler returns when its finished
		if(vertexCount==Integer.parseInt(this.maxNodeField.getText())){
			//RedrawGraph();
			drawGraph(graph);
			jProgressBar_MainFrame.setIndeterminate(false);
			goButton.setEnabled(true);
			pauseButton.setEnabled(false);
		}
		

	}

	//Advanced URLS are stored here
	public ArrayList<String> advancedURLS = new ArrayList<String>();
	//Advanced URLS are stored here
	private void goButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_goButtonActionPerformed
		// TODO add your handling code here:
		System.out.println("Go Button Pressed");
		graphIsSetup = false;
		redrawCount = 1;
		setupWebCrawler();
		jProgressBar_MainFrame.setIndeterminate(true);

		// jScrollPane_GraphDrawingArea.removeAll();
		System.out.println("Starting the Crawler");
		// Submit URL to crawler
		goButton.setEnabled(false);
		pauseButton.setEnabled(true);
		minimizeButton.setEnabled(true);
		redrawButton.setEnabled(true);
		try {
			crawler.submit(this.urlField.getText());
			if(advancedURLS.size()>0){
				System.out.println("Starting the Crawler, with addtional URLS");
				for(String s : advancedURLS)
				{
					crawler.submit(s);
				}
			}

			// drawGraph(graph);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (FoundMaxException e) {
			e.printStackTrace();
		}
	}// GEN-LAST:event_goButtonActionPerformed

	private void loadOptionActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_loadOptionActionPerformed
		// TODO add your handling code here:
		LoadFrame loadFrame = new LoadFrame(this);
		loadFrame.setVisible(true);

		// this.jDialog_LoadGraph.setVisible(false);

		System.out.println("Load Action Pressed");
	}// GEN-LAST:event_loadOptionActionPerformed

	public void loadGraph(String fname) {
		System.out.println("Trying to load graph");
		graphIsSetup = false;
		// int SelectedGraphIndex = loadFrame.getJlist().getSelectedIndex();
		// jProgressBar_MainFrame.setIndeterminate(true);
		
		DirectedGraph<URL, Integer> loadedGraph;
		try {
			System.out.println("Graph Should now load " + fname + " working dir is "+ filePath);
			loadedGraph = graphDB.loadCustomGraph(fname);
			graph = loadedGraph;
			graphPanel.removeAll();
			drawGraph(graph);
			
			this.nodeCountLabel.setText("Node Count "+graph.getVertexCount());

		} catch (Exception e) {
			System.out.println("Graph failed to load");
			e.printStackTrace();
			return;
		}
		jProgressBar_MainFrame.setIndeterminate(false);
		goButton.setEnabled(true);
		pauseButton.setEnabled(false);
		minimizeButton.setEnabled(true);
		redrawButton.setEnabled(true);

	}
	
	public void addAdvancedURLS(DefaultListModel dlModel){
		//advancedURLS
		for(int i=0;i<dlModel.size();i++){
			advancedURLS.add((String)dlModel.get(i));
		}
	}

	public void saveGraph(String fname) {
		JFrame frame = new JFrame();
		jProgressBar_MainFrame.setIndeterminate(true);
		if (!fname.matches("")) {
			if (graphDB.saveGraph(fname, graph)) {
				JOptionPane.showMessageDialog(frame, "Save succeed");
			} else {
				JOptionPane.showMessageDialog(frame, "Error saving on graph, try setting Graph directory",
						"Error", JOptionPane.ERROR_MESSAGE);
			}
		} else {
			JOptionPane.showMessageDialog(frame,
					"Error on saving on graph, no name entered", "Error",
					JOptionPane.ERROR_MESSAGE);
		}
		jProgressBar_MainFrame.setIndeterminate(false);

	}

	//private Map<URL,Icon> iconMap = new HashMap<URL,Icon>();
	
	public VisualizationViewer<URL, Integer> vv2;
	
	boolean graphIsSetup = false;
	private void drawGraph(DirectedGraph<URL, Integer> passedGraph) {
		
		
		if (graphDetailComboBox.getSelectedIndex() == 1) {
			passedGraph = minimizeGraph();
			setupGraphViewer(passedGraph);
			return;
		}
				
		
		if(passedGraph==null){
			countLabel.setText("Nodes Displayed "+0);
		}else {
			countLabel.setText("Nodes Displayed "+passedGraph.getVertexCount());
		}
		
		
		if(!graphIsSetup){
			System.out.println("RESETUP");
			
			setupGraphViewer(passedGraph);
			graphIsSetup = true;
		}

		if(vv2!=null){
			vv2.repaint();
		}		
	}

	private void setupGraphViewer(DirectedGraph<URL, Integer> passedGraph){
		if(passedGraph==null){
			graphPanel.removeAll();
			graphPanel.revalidate();
			return;
		}
		
		

		//Layout Selector
		AggregateLayout<URL,Integer> layout =null;
		
		switch (useLayout){
		case 0:{
			layout = 
	        	new AggregateLayout<URL,Integer>(new FRLayout2<URL,Integer>(passedGraph));
		}
		break;
		case 1:{
			layout = 
	        	new AggregateLayout<URL,Integer>(new CircleLayout<URL,Integer>(passedGraph));
				}
		break;
		case 2:{
			layout = 
	        	new AggregateLayout<URL,Integer>(new ISOMLayout<URL,Integer>(passedGraph));
		}
		break;
		case 3:{
			layout = 
	        	new AggregateLayout<URL,Integer>(new KKLayout<URL,Integer>(passedGraph));
		}
		break;
		default:{
			layout = 
	        	new AggregateLayout<URL,Integer>(new FRLayout2<URL,Integer>(passedGraph));
		}
		break;
		}
		
		int nodeCount = passedGraph.getVertexCount();
	
		
		int newWidth= graphPanel.getBounds().width;
		int newHeight = graphPanel.getBounds().height;
		
		newWidth = newWidth+(int)(newWidth*nodeCount*0.0015);
		newHeight = newHeight+(int)(newHeight*nodeCount*0.0015);
		
		System.out.println("org width "+graphPanel.getBounds().width+" new width"+newWidth);
		
		VisualizationViewer<URL, Integer> vv = new VisualizationViewer<URL, Integer>(
				layout, new Dimension(newWidth,
						newHeight));
		
		vv2 = vv;
	
	//	vv.resize( new Dimension(newWidth,newHeight));

		
//		((FRLayout2)vv.getModel().getGraphLayout()).setMaxIterations(10);
//		
//
//		if (nodeCount < 300) {
//			((FRLayout2)vv.getModel().getGraphLayout()).setMaxIterations(50);
//
//		}
//
//		if (nodeCount < 150) {
//			((FRLayout2)vv.getModel().getGraphLayout()).setMaxIterations(150);
//		}
//
//		if (nodeCount < 80) {
//			((FRLayout2)vv.getModel().getGraphLayout()).setMaxIterations(200);
//		}
//
//		if (nodeCount < 20) {
//			((FRLayout2)vv.getModel().getGraphLayout()).setMaxIterations(300);
//		}
		
		Relaxer relaxer = vv.getModel().getRelaxer();
		
	    relaxer.prerelax();  
	    		
		vv.setLayout(new BorderLayout());
		vv.setBackground(java.awt.Color.white);
		vv.setFont(new Font("Serif", Font.PLAIN, 12));
		//vv.getModel().getRelaxer().prerelax();
		//vv.getModel().getRelaxer().stop();
		//vv.getModel().getRelaxer().setSleepTime(500);
			
		ModalGraphMouse gm = new DefaultModalGraphMouse<URL, Integer>();
		if (mouseComboBox.getSelectedIndex() == 1) {
			gm.setMode(ModalGraphMouse.Mode.PICKING);
			vv.setGraphMouse(gm);
		}
		else
		{
			gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
			vv.setGraphMouse(gm);
		}

		Transformer<URL, String> nodeLabelTransform = new Transformer<URL, String>() {
			public String transform(URL url) {
				String str = url.getHost();
				
//				URL imgURL;
//				try {
//					
//					imgURL = new URL(url.getProtocol()+"://"+ url.getHost()+ "/favicon.ico");
//					
//					if(!iconMap.containsKey(url)){
//						System.out.println("Adding "+imgURL.toString());
//						//Icon icon = new LayeredIcon(new ImageIcon("c:/add_down.gif").getImage());
//
//						//Icon icon = new LayeredIcon(new ImageIcon(imgURL).getImage());
//						Icon icon = new ImageIcon(imgURL);		
//												
//						if(icon.getIconHeight()==-1){
//							icon = new LayeredIcon(new ImageIcon("src/nz/ac/massey/spidernetpn/gui/resources/add_down.gif").getImage());
//						}
//						
//						System.out.println("icon height "+icon.getIconHeight()+icon.toString());
//						iconMap.put(url, icon);
//					}
//				
//				} catch (MalformedURLException e) {
//					e.printStackTrace();
//				}

				return str;
			}
		};

		Transformer<URL, String> vertexTooltips = new Transformer<URL, String>() {
			public String transform(URL url) {
				String urlString = url.toString();
				// This is how you do multi line tool tips, seperate with <p>
				// How to make clickable?
				// Get current delay
			    int dismissDelay = ToolTipManager.sharedInstance().getDismissDelay();
			    // Keep the tool tip showing
			    dismissDelay = Integer.MAX_VALUE;
			    ToolTipManager.sharedInstance().setDismissDelay(dismissDelay);
			    //JToolTip tip = new JToolTip();
			    
				return ("<html>Full URL<p><A HREF=\"" + urlString + "\">"
						+ urlString + "</A>");
			}
		};

		vv.setVertexToolTipTransformer(vertexTooltips);
		
		boolean useClusteringColours = useClustering.isSelected();
		
		 EdgeBetweennessClusterer<URL,Integer> clusterer =
				new EdgeBetweennessClusterer<URL,Integer>(0);
			final Set<Set<URL>> clusterSet = clusterer.transform(passedGraph);
		
		if(useClusteringColours){
  				
				Transformer<URL, Paint> nodeColorTransform = new Transformer<URL, Paint>() {
					public Paint transform(URL url) {

						
						Color[] newColors = {Color.YELLOW,Color.GREEN,Color.BLUE,Color.RED};
						int setNumber =0;
						for (Iterator<Set<URL>> cIt = clusterSet.iterator(); cIt.hasNext();) {

							Set<URL> vertices = cIt.next();
							if(vertices.contains(url)){
								return newColors[setNumber%4];
							}
							setNumber++;
						}
						return Color.WHITE;
					}

				};
				vv.getRenderContext().setVertexFillPaintTransformer(nodeColorTransform);
				
		} else{ //use Normal colouring

			Transformer<URL, Paint> nodeColorTransform = new Transformer<URL, Paint>() {
				public Paint transform(URL url) {
					URL shortURL = null;
					URL shortURL2 = null;
					try {
						shortURL = new URL(url.getProtocol()+"://" + url.getHost());
						shortURL2 = new URL(url.getProtocol()+"://" + url.getHost()+ "/");
						// System.out.println("Start url "+url.toString()+" compared to final "+shortURL.toString());
					} catch (MalformedURLException e) {
						System.out.println("Problem getting URL for color");
						e.printStackTrace();
					}
	
					if (shortURL == null) {
						return Color.RED;
					}
	
					if (shortURL.equals(url) || shortURL2.equals(url)) {
						return Color.GREEN;
					} else {
						return Color.RED;
					}
				}
			};
				vv.getRenderContext().setVertexFillPaintTransformer(nodeColorTransform);
		}
				
//		 VertexIconShapeTransformer<URL> vertexIconShapeTransformer =
//	            new VertexIconShapeTransformer<URL>(new EllipseVertexShapeTransformer<URL>());
//		 
//		 DefaultVertexIconTransformer<URL> vertexIconTransformer =
//	        	new DefaultVertexIconTransformer<URL>();
//		// vertexIconShapeTransformer
//		 vertexIconShapeTransformer.setIconMap(iconMap);
//	     vertexIconTransformer.setIconMap(iconMap);
//		  
//		 vv.getRenderContext().setVertexIconTransformer(vertexIconTransformer);
//		 vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeTransformer);
		

       // Transformer<URL,Paint> vpf = 
        //    new PickableVertexPaintTransformer<URL>(vv.getPickedVertexState(), Color.white, Color.yellow);
        //vv.getRenderContext().setVertexFillPaintTransformer(vpf);
       // vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<URL>(vv.getPickedEdgeState(), Color.black, Color.cyan));

		
		vv.getRenderer().getVertexLabelRenderer().setPosition(
				Renderer.VertexLabel.Position.S);
		vv.getRenderContext().setVertexLabelTransformer(nodeLabelTransform);
		vv.setForeground(new java.awt.Color(0, 0, 0));
		
		if(useClusteringColours){
			for (Iterator<Set<URL>> cIt = clusterSet.iterator(); cIt.hasNext();) {
				Set<URL> vertices = cIt.next();
				groupCluster(layout,vertices,vv);
			}
		}
		
		graphPanel.removeAll();
		graphPanel.add(new GraphZoomScrollPane(vv));
		Integer vertexCount = passedGraph.getVertexCount();
		countLabel.setText("Nodes Displayed "+vertexCount.toString());
		graphPanel.revalidate();
	}
	
	private void groupCluster(AggregateLayout<URL,Integer> layout, Set<URL> vertices,VisualizationViewer<URL, Integer> vv) {
		if(vertices.size() < layout.getGraph().getVertexCount()) {
			Point2D center = layout.transform(vertices.iterator().next());
			Graph<URL,Integer> subGraph = SparseMultigraph.<URL,Integer>getFactory().create();
			for(URL v : vertices) {
				subGraph.addVertex(v);
			}
			Layout<URL,Integer> subLayout;
			switch (useLayout){
			case 0:{
				subLayout = 
		        	new FRLayout2<URL,Integer>(subGraph);
			}
			break;
			case 1:{
				subLayout = 
		        	new CircleLayout<URL,Integer>(subGraph);
					}
			break;
			case 2:{
				subLayout = 
		        	new ISOMLayout<URL,Integer>(subGraph);
			}
			break;
			case 3:{
				subLayout = 
		        	new KKLayout<URL,Integer>(subGraph);
			}
			break;
			default:{
				subLayout = 
		        	new FRLayout2<URL,Integer>(subGraph);
			}
			break;
			}
			
//			
//			Layout<URL,Integer> subLayout = 
//				new FRLayout2<URL,Integer>(subGraph);
			//subLayout.setInitializer(vv.getGraphLayout());
			//subLayout.setInitializer(graph.g);
			subLayout.setSize(new Dimension((int)(subGraph.getVertexCount()/2),(int)(subGraph.getVertexCount()/2)));

			layout.put(subLayout,center);
			
			vv.repaint();
			
		}
	}
	
	private DirectedGraph<URL, Integer> minimizeGraph() {

		
		if(graph==null){
			return null;
		}
		// Pause crawler
		DirectedGraph<URL, Integer> orgGraph = graph;
		
		// Unpause
		DirectedGraph<URL, Integer> newGraph = new DirectedSparseMultigraph<URL, Integer>();
		HashSet<URL> storedVertices = new HashSet<URL>();
		HashSet<Pair<URL>> storedEdges = new HashSet<Pair<URL>>();
		int edgeCount = 0;

		// EdgeType et = EdgeType.DIRECTED;
		Collection<URL> vertices = orgGraph.getVertices();
		Collection<Integer> edges = orgGraph.getEdges(orgGraph.getEdgeType(0));

		Iterator edgesIter = edges.iterator();
		Iterator verticesIter = vertices.iterator();

		while (verticesIter.hasNext()) {
			URL newURL = (URL) verticesIter.next();
			try {
				newURL = new URL(newURL.getProtocol()+"://" + newURL.getHost());
			} catch (MalformedURLException e) {
				System.out.println("Problem converting to URL");
				e.printStackTrace();
			}

			if (storedVertices.add(newURL)) {
				newGraph.addVertex(newURL);
			}
		}

		while (edgesIter.hasNext()) {
			// Pair<URL> newEdge = (Pair<URL>)edgesIter.next();
			int edgeIndex = (Integer) edgesIter.next();
			// Pair<URL> newEdge = graph.getDest(edgeIndex);

			URL source = orgGraph.getSource(edgeIndex);
			URL dest = orgGraph.getDest(edgeIndex);

			if (source == null || dest == null) {
				System.out.println("Null source or dest");
				continue;
			}
			// System.out.println("Source "+graph.getSource(edgeIndex));

			try {
				source = new URL(source.getProtocol()+"://"
						+ orgGraph.getSource(edgeIndex).getHost());
				dest = new URL(dest.getProtocol()+"://"
						+ orgGraph.getDest(edgeIndex).getHost());
			} catch (MalformedURLException e) {
				System.out.println("Problem converting pairs");
				e.printStackTrace();
			}

			Pair<URL> finalEdge = new Pair<URL>(source, dest);

			if (storedEdges.add(finalEdge)) {
				newGraph.addEdge(edgeCount, source, dest);
				edgeCount++;
			}

		}

		storedVertices.clear();
		storedEdges.clear();

		return newGraph;

	}
	
	
	
	private void SetGraphFolderDialog(ActionEvent evt){

		JFileChooser fileopen = new JFileChooser();
		fileopen.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
		int ret = fileopen.showDialog(null, "Open file");

	    if (ret == JFileChooser.APPROVE_OPTION) {
	      String file = fileopen.getSelectedFile().toString()+"/";
	      filePath = file;
	      graphDB.setGraphsLocation(filePath);
	      System.out.println(file);
	    }
		
	}

	private void RedrawGraph() {
		System.out.println("Redrawing");
		graphIsSetup = false;
		// Put code here to only show progress bar if not already working
		if (jProgressBar_MainFrame.isIndeterminate()) {
			drawGraph(graph);
			graphPanel.revalidate();
		} else {
			jProgressBar_MainFrame.setIndeterminate(true);
			drawGraph(graph);
			graphPanel.revalidate();
			jProgressBar_MainFrame.setIndeterminate(false);
		}

	}

	private void saveOptionActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_saveOptionActionPerformed
		// TODO add your handling code here:
		SaveFrame saveFrame = new SaveFrame(this);
		saveFrame.setVisible(true);
		System.out.println("Save Action Pressed");


	}// GEN-LAST:event_saveOptionActionPerformed

	private void placeholderActionActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_placeholderActionActionPerformed

	}
	private void changeLayoutActionActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_placeholderActionActionPerformed

	}
	
	
	
	private void changeToFH(java.awt.event.ActionEvent evt)	{
		try{
	        UIManager.setLookAndFeel("com.shfarr.ui.plaf.fh.FhLookAndFeel");
			SwingUtilities.updateComponentTreeUI(this);
	    }
	    catch (Exception e) {
	    	JFrame frame = new JFrame();
	    	JOptionPane.showMessageDialog(frame,
					"Error on changing the outlook", "Error",
					JOptionPane.ERROR_MESSAGE);
	    }
	}
	
	private void changeToOffice(java.awt.event.ActionEvent evt)	{
		try{
	        UIManager.setLookAndFeel("org.fife.plaf.Office2003.Office2003LookAndFeel");
			SwingUtilities.updateComponentTreeUI(this);
	    }
	    catch (Exception e) {
	    	JFrame frame = new JFrame();
	    	JOptionPane.showMessageDialog(frame,
					"Error on changing the outlook", "Error",
					JOptionPane.ERROR_MESSAGE);
	    }
	}
	
	private void changeToMetal(java.awt.event.ActionEvent evt)	{
		try{
			String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
			UIManager.setLookAndFeel(lookAndFeel);
			MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
			UIManager.setLookAndFeel(new MetalLookAndFeel());
			SwingUtilities.updateComponentTreeUI(this);
	    }
	    catch (Exception e) {
	    	JFrame frame = new JFrame();
	    	JOptionPane.showMessageDialog(frame,
					"Error on changing the outlook", "Error",
					JOptionPane.ERROR_MESSAGE);
	    }
	}
	
	private void changeTomotif(java.awt.event.ActionEvent evt)	{
		try{
			String lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
			UIManager.setLookAndFeel(lookAndFeel);
			SwingUtilities.updateComponentTreeUI(this);
	    }
	    catch (Exception e) {
	    	JFrame frame = new JFrame();
	    	JOptionPane.showMessageDialog(frame,
					"Error on changing the outlook", "Error",
					JOptionPane.ERROR_MESSAGE);
	    }
	}
	
	private void changeToWindows(java.awt.event.ActionEvent evt)	{
		try{
			String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
			UIManager.setLookAndFeel(lookAndFeel);
			SwingUtilities.updateComponentTreeUI(this);
	    }
	    catch (Exception e) {
	    	JFrame frame = new JFrame();
	    	JOptionPane.showMessageDialog(frame,
					"Error on changing the outlook", "Error",
					JOptionPane.ERROR_MESSAGE);
	    }
	}
	boolean crawlerIsPaused = false;
	private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_stopButtonActionPerformed
		System.out.println("It's " + crawlerIsPaused + "!");
		
		if (crawlerIsPaused) {
			// It's paused! Unpausing now.
			crawler.unpause();
			crawlerIsPaused = false;
			pauseButton.setText("Pause");
		}
		else {
			// It's unpaused! Pausing now.
			crawler.pause();
			crawlerIsPaused = true;
			pauseButton.setText("Unpause");
		}

		jProgressBar_MainFrame.setIndeterminate(false);
	}// GEN-LAST:event_pauseButtonActionPerformed

	private void advanceButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_advanceButtonActionPerformed
		// TODO add your handling code here:
		OptionFrame optionFrame = new OptionFrame(this);
		optionFrame.setVisible(true);
		System.out.println("Advanced Button Pressed");
	}// GEN-LAST:event_advanceButtonActionPerformed

	private void exitMenuActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_exitMenuActionPerformed
		// TODO add your handling code here:
		System.exit(0);
	}// GEN-LAST:event_exitMenuActionPerformed

	private void newOptionActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_newOptionActionPerformed
		// TODO add your handling code here:
		//MainFrame m = new MainFrame();
		//m.setVisible(true);
		this.graph = null;
		crawler = null;
		this.advancedURLS.clear();
		
		this.crawlerIsPaused = false;
		this.jProgressBar_MainFrame.setIndeterminate(false);
		this.redrawCount = 1;
		this.goButton.setEnabled(true);
		this.minimizeButton.setEnabled(false);
		this.redrawButton.setEnabled(false);
		this.graphPanel.revalidate();
		this.graphIsSetup = false;
		this.drawGraph(graph);
		this.countLabel.setText("0");
		this.repaint();
		
	}// GEN-LAST:event_newOptionActionPerformed

	private void maxDepthFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_maxDepthFieldActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_maxDepthFieldActionPerformed

	private void mouseComboBoxActionPerformed(
			java.awt.event.ActionEvent evt) {// GEN-FIRST:event_graphDetailComboBoxActionPerformed
		// TODO add your handling code here:
		// Combo box changes
	}// GEN-LAST:event_graphDetailComboBoxActionPerformed

	private void GraphComboBoxActionPerformed(
			java.awt.event.ActionEvent evt) {// GEN-FIRST:event_graphDetailComboBoxActionPerformed
		// TODO add your handling code here:
		// Combo box changes
	}// GEN-LAST:event_graphDetailComboBoxActionPerformed
	
	private void minimizeButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_minimizeButtonActionPerformed
		// TODO add your handling code here:
		// Minize Graph
		// minimizeGraph();
		drawGraph(minimizeGraph());
	}// GEN-LAST:event_minimizeButtonActionPerformed

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new MainFrame().setVisible(true);
			}
		});
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton advanceButton;
	private javax.swing.JLabel countLabel;
	private javax.swing.JMenuItem exitMenu;
	private javax.swing.JMenu fileMenu;
	private javax.swing.JButton goButton;
	private javax.swing.JComboBox graphComboBox;
	private javax.swing.JLabel graphLabel;
	private javax.swing.JComboBox mouseComboBox;
	private javax.swing.JComboBox graphDetailComboBox;
	private javax.swing.JLabel graphDetailLabel;
	private javax.swing.JLabel mouseLabel;
	private javax.swing.JPanel graphPanel;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JPanel jPanel1;
	javax.swing.JProgressBar jProgressBar_MainFrame;
	private javax.swing.JMenuItem loadOption;
	private javax.swing.JPanel mainPanel;
	private javax.swing.JTextField maxDepthField;
	private javax.swing.JLabel maxDepthLabel;
	private javax.swing.JTextField maxNodeField;
	private javax.swing.JLabel maxNodeLabel;
	private javax.swing.JMenuBar menuBar;
	private javax.swing.JButton minimizeButton;
	private javax.swing.JMenuItem newOption;
	private javax.swing.JLabel nodeCountLabel;
	private javax.swing.JLabel optionLabel;
	private javax.swing.JMenu optionMenu;
	private javax.swing.JPanel optionPanel1;
	private javax.swing.JPanel optionsFlowPanel;
	private javax.swing.JMenuItem placeholderAction;
	private javax.swing.JButton redrawButton;
	private javax.swing.JMenuItem saveOption;
	private javax.swing.JPanel statusPanel;
	private javax.swing.JButton pauseButton;
	private javax.swing.JTextField urlField;
	private javax.swing.JCheckBox useProxyCheck;
	private javax.swing.JCheckBox useClustering;
	private javax.swing.JMenuItem FH;
	private javax.swing.JMenuItem office;
	private javax.swing.JMenuItem motif;
	private javax.swing.JMenuItem Windows;
	private javax.swing.JMenuItem setGraphFolder;
	private javax.swing.JMenuItem metal;
	private javax.swing.JMenu changeLayout;
	private JMenuItem menuFRLayout;
	// End of variables declaration//GEN-END:variables

	public String getFilePath() {
		return filePath;
	}

}
